package com.sk.bilibili.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

//  getSmartTime  按 时间间隔 进行返回内容
public class TimeUtils {

    private static final SimpleDateFormat FULL_TIME_FORMAT=new SimpleDateFormat("yyyy-MM-dd");
    private static final SimpleDateFormat SHOT_TIME_FORMAT=new SimpleDateFormat("MM-dd");
    private static final SimpleDateFormat HISTORY_TIME_FORMAT=new SimpleDateFormat("MM-dd HH:mm");
    private static final int HOUR=1000*60*60;
    private  static final String[] WEEKS = "一,二,三,四,五,六,日".split(",");

    public static String getFullTime(Long time){
        return FULL_TIME_FORMAT.format(new Date(time));
    }

    public static String getShotTime(Long time) {
        return SHOT_TIME_FORMAT.format(new Date(time));
    }

    public static String getHistoryTime(Long time) {
        return HISTORY_TIME_FORMAT.format(new Date(time));
    }

    public static String getProcessTime(long current, long duration) {
        return String.format("%s/%s",toTime(current/1000),toTime(duration/1000));
    }

    public static String toTime(long value) {
        return String.format("%02d:%02d",value/60,value%60);
    }

    public static String getPastTime(Long time) {
        return String.format("%d小时前",(System.currentTimeMillis()-time)/HOUR);
    }

    // 0 周一  以此类推
    public static int getWeek() {
        int week = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
        return (week+5)%7;
    }

    public static String getWeekStr(int index){
        return WEEKS[index];
    }

}